<?php
apf_require_class('APF_Controller');
apf_require_class('Solr_Bll_AppBiz');
class Application_ListController extends APF_Controller {

    public static function build_uri() {
        $base_domain = APF::get_instance()->get_config("base_domain");
        $schema = APF::get_instance()->get_request()->is_secure() ? "https" : "http";
        $url = "{$schema}://{$base_domain}/application/list/";
        return $url;
    }

    public function handle_request() {

        $request = APF::get_instance()->get_request();
        $params = $request->get_parameters();
        $hostname_id=@intval($params['hostname_id']);
        $port=@intval($params['port']);

        $app_biz=Solr_Bll_AppBiz::get_instance();
        $hostnames=$app_biz->get_all_hostname();
        $webapps=$app_biz->get_all_webapp();
        $request->set_attribute('hostnames',$hostnames);
        $request->set_attribute('webapps',$webapps);

        $app_list=$app_biz->get_apps_list($hostname_id,$port);
        $request->set_attribute('app_list',$app_list);

        $port_list=$app_biz->get_port_list();
        $request->set_attribute('port_list',$port_list);

        $request->set_attribute('params',$params);

        return 'Application_List';
    }
}